package org.example.project

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import kotlinproject.composeapp.generated.resources.Res
import kotlinproject.composeapp.generated.resources._941735022379
import kotlinproject.composeapp.generated.resources._951735022410
import kotlinproject.composeapp.generated.resources._961735022446
import org.jetbrains.compose.resources.painterResource

/**
 * 头图组件
 *
 * @author Gaoyf
 * @since 2025/1/23
 */
@Composable
fun HeaderPicRow(
    picList: List<String>? = null,
    height: Int = 120
) {

    val imgList = listOf(
        Res.drawable._941735022379,
        Res.drawable._961735022446,
        Res.drawable._951735022410
    )

    Box(
        modifier = Modifier.fillMaxWidth()
            .height(height.dp)
            .background(color = Color.White, shape = RoundedCornerShape(16.dp))
            .padding(10.dp),
    ) {
        Row(
            modifier = Modifier
                .fillMaxSize()
                .clip(RoundedCornerShape(8.dp)),
            horizontalArrangement = Arrangement.spacedBy(2.dp)
        ) {
            imgList.forEachIndexed { index, it ->
                if (index < 3){
                    Image(
                        painter = painterResource(it),
                        contentDescription = "",
                        contentScale = ContentScale.Crop,
                        modifier = Modifier.fillMaxHeight().weight(1f)
                    )
                }
            }
        }

        Box(
            modifier = Modifier.align(Alignment.BottomEnd).padding(10.dp)
                .background(Color.Black, RoundedCornerShape(10.dp))
                .padding(top = 3.dp, bottom = 3.dp, start = 6.dp, end = 6.dp)
        ) {
            Text("${imgList.size}张", fontSize = 10.sp, fontWeight = FontWeight.W400, color = Color.White)
        }

    }

}